package bnetwork;

public class Block {

	private static final int SENSOR_RANGE = 5;

	int x;
	int y;
	int region;
	int cell;
	int sensed = 0;
	final static int maxSensed = 2;

	public Block(int x, int y, int region, int cell){
		this.x = x;
		this.y = y;
		this.region = region;
		this.cell = cell;
	}

	public int getX(){
		return x;
	}
	public int getY(){
		return y;
	}
	public int getRegion(){
		return region;
	}
	public int getCell(){
		return cell;
	}

	public boolean isClose(int x, int y){
		return getEuclidianDistance(this.x, this.y, x, y)<=SENSOR_RANGE;
	}

	private static double getEuclidianDistance(int i, int j, int x, int y) {
		int tmp1 = i-x;
		int tmp2 = j-y;
		tmp1 = tmp1*tmp1;
		tmp2 = tmp2*tmp2;
		return Math.sqrt(tmp1+tmp2);
	}

	public boolean canSense(){
		return maxSensed > sensed;
	}
}
